package SM::Server::Packet::In::Avatar::AuthReq;

use strict;
use warnings;

use Data::Dumper::Simple;

use SM::Constants;

use base 'SM::Server::Packet::In::Avatar';

sub new {
    my ( $class, $arg_ref ) = @_;

    my $self = $class->SUPER::new($arg_ref);

    $self->{sub_type} = AVATAR_AUTHREQ;

    my ( $data_type, $sub_type, $username, $password ) = unpack "CCZ*Z*", $arg_ref->{raw_data};

    $self->{username} = $username;
    $self->{password} = $password;

    return $self;
}

sub dispatch {
    my ($self) = @_;
    SM::Server::GameLogic::initialize_client->({
        username => $self->{username},
		password => $self->{password},
        client => $self->{client},
    });
}

sub get_username {
    my ($self) = @_;

    return $self->{username};
}

1;
